/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

/**
 *
 * @author griever
 */
public class Fields {
    
    public static Object getField(Object obj, String field) {
        try {
            return obj.getClass().getField(field).get(obj);
        } catch (Exception ex)  {
            return null;
        }
    }
    
    public static Object getField(Object obj, String field, Object defaultValue) {
        try {
            return obj.getClass().getField(field).get(obj);
        } catch (Exception ex)  {
            return defaultValue;
        }
    }
    
    public static void setField(Object obj, String field, Object value) {
        try {
            obj.getClass().getField(field).set(obj, value);
        } catch (Exception ex)  {
        }
    }
}
